home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 18 code / OSA Sample / Sources / TrapAvailable.cp < prev    next >
Encoding:
Text File  |  1993-05-04  |  938 b   |  50 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TrapAvailable.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Copyright:    © 1991 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __TRAPS__
  11. #include <Traps.h>
  12. #endif
  13.  
  14. /**********************************************************************
  15. ** TrapAvailable
  16. ***********************************************************************/
  17.  
  18. short NumToolboxTraps()
  19. {
  20.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
  21.         return 0x200;
  22.     else
  23.         return 0x400;
  24. }
  25.  
  26.  
  27. TrapType GetTrapType(short theTrap)
  28. {
  29.     const TrapMask = 0x800;
  30.  
  31.     if ((theTrap & TrapMask) > 0)
  32.         return ToolTrap;
  33.     else
  34.         return OSTrap;
  35. }
  36.  
  37. Boolean TrapAvailable(short theTrap)
  38. {
  39.     TrapType tType;
  40.     
  41.     tType = GetTrapType(theTrap);
  42.     if (tType == ToolTrap) {
  43.         theTrap = (theTrap & 0x07ff);
  44.         if (theTrap >= NumToolboxTraps())
  45.             theTrap = _Unimplemented;
  46.     }
  47.     
  48.     return NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  49. }
  50.